<template>
    <div>
        <van-icon name="arrow-left"  @click="gohome()"/>
         <Tabbar/>
         <header>
             <li>申请人</li>
             <li>申请时间</li>
             <li>状态</li>
         </header>
         <div class="contain">
              <van-list
                v-model="loading"
                :finished="finished"
                finished-text="没有更多了"
                @load="onLoad"
                >
                <ul v-for="item in list" :key="item.id">
                    <li @click="select(item)" id="list">
                    <span style="width:25%">{{item.approver_name}}</span>
                    <span style="width:44%;padding-top:5px;">{{item.apply_time}}</span>
                    <van-button round  size="mini" type="primary" style="width:20%;font-size:10px;">{{item.whether_end}}</van-button>
                    </li>
                </ul>
                </van-list>
       </div>
    </div>
</template>
<script>
import BScroll from '@better-scroll/core'
import axios from 'axios'
import {getCookie} from 'Utils/cookie'
import Tabbar from 'Comp/Tabbar'
export default {
    data(){
         return{
       list: [],
      loading: false,
      finished: false,
      pagelimit:1,
       
    }
    },
    components:{
    Tabbar,
  },
  methods:{
    gohome(){
      this.$router.push('/select');
    },
     // 上拉加载
    onLoad() {
         axios({
      url:'/hrkc/buyApply/queryIngList',
      method:'GET',
      params:{
         pagesize:10,
         pagelimit:this.pagelimit,
         apply_status:'ing',
         org_name:getCookie('org_name'),
         user_id:getCookie('approver_b_id'),
         user_flag:`${getCookie('user_flag')}`
        },
    }).then(res=>{
      console.log('res1111',res)
      if(res.data.code == 0){

        for (let i = 0; i < res.data.data.length; i++) {
          
           var item = {};
            item.approver_name = res.data.data[i].apply_user;
            item.apply_time =  res.data.data[i].apply_date.substring(0,res.data.data[i].apply_date.length-5);
            item.apply_id = res.data.data[i].id;
            item.approver_id = res.data.data[i].user_id
            if(res.data.data[i].apply_status == 'ing'){
              item.whether_end = '正在进行中';
            }
            
            this.list.push(item);
        }
        this.pagelimit = this.pagelimit+1;
      }else{
        this.finished = true;
      }
      this.loading = false;
    }).catch(error =>Promise.reject(error))
    },

    select(item){
      console.log(item)

      this.$router.push({
        path:'/goods_check',
        query:{
          data:JSON.stringify(item)
        }
      })
    }
  },
  
    
}
</script>
<style lang="scss" scoped>
li{
    list-style: none;
     
}
#list{
  height:30px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-bottom: 1px solid #ccc;
}
.contain{
    height: 565px;
    overflow: scroll;
    background-color: #F7F8FA;
}
header{
    display: flex;
    justify-content: space-around;
    height: 50px;
    text-align: center;
    line-height: 50px;
    // background-color: #00CC66;
    border-bottom: 1px solid #ccc;
    z-index: 999;
}
.van-icon{
  position: absolute;
  top:20px;
  left:0px;

}

</style>